package com.yijiajiao.finance.controller;

import com.yijiajiao.finance.bean.FinanceLog;
import com.yijiajiao.finance.bean.FinanceLogQuery;
import com.yijiajiao.finance.bean.ResultBean;
import com.yijiajiao.finance.service.FinanceLogService;
import com.yijiajiao.finance.service.TeacherMoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @AUTHOR zhaoming@eduspace
 * @CREATE 2017-02-21-16:10
 */
@RestController
@RequestMapping("/FinanceLog")
public class FinanceLogController {

    @Autowired
    private FinanceLogService financeLogService;
    @Autowired
    private TeacherMoneyService teacherMoneyService;

    /**
     * 订单记录
     */
    @PostMapping("/orderFinanceLog")
    public ResultBean orderFinanceLog(@RequestBody FinanceLog financeLog){

        return financeLogService.addOrderFinanceLog(financeLog);

    }

    /**
     * 退款记录
     */
    @PostMapping("/refundMoney")
    public ResultBean refundFinanceLog(FinanceLog financeLog){

        return financeLogService.addRefundFinanceLog(financeLog);

    }

    /**
     *  获取个人用户所剩金额
     */
    @GetMapping("/getRemainMoney")
    public ResultBean getRemainMoney(String openId) {

        return teacherMoneyService.getRemainMoney(openId);

    }

    /**
     * 通过手机号和时间获取教师交易详情列表
     *@Date 2017/5/24 14:54
     */
    @PostMapping("/personalFinance")
    public ResultBean personalFinanceLogs(@RequestBody FinanceLogQuery flq){

        return financeLogService.queryTeacherTradeLogs(flq);

    }
}
